Ext.onReady(function() {
//head
	var header = Ext.create('Index.Toolbar',{
		region : 'north',
		id: 'header'
	});
	
//menu
	var menuStore = Ext.create('Ext.data.TreeStore', {
		proxy: {
			type : 'ajax',
			url : ctx+'/aa/po/index.do?md=menu',
			loadMask : true
		},
		sorters: [{
	        property: 'order',
	        direction: 'ASC'
	    }]
	});

	var menuTree = Ext.create('Ext.tree.Panel', {
		region : 'west',
		useArrows: true,
		title : str_index_navi,
		width : 200,
		maxWidth : 400,
		collapsible : true,
		animCollapse : true,
		split : true,
		store : menuStore,
		rootVisible: false,
		autoScroll : true
	});
	
	menuTree.getSelectionModel().on('select', function(selModel, record) {
		if (record.get('leaf')) {
			tabs.addTab(record.raw.id, record.get('text'), getPath(record.raw.link), record.raw.iconCls, record.raw.path);
		}
	});
	
	var tabs = Ext.create('Ext.tab.Panel', {
		region : 'center',
		activeItem : 0,
		frameHeader : true,
		items : [{
			id : 'center',
			title : "&nbsp;&nbsp;" + str_index_home + "&nbsp;&nbsp;",
			html: "<iframe width='100%' frameborder='0' height='100%' src='" + getPath('/aa/page/home.jsp') + "'></iframe>",
			listeners : {
				show : {
					fn : function(){
						menuTree.getSelectionModel().deselectAll();
					}
				}
			}
		}],
		plugins: Ext.create('Ext.ux.TabCloseMenu',{}),
		addTab : function(id, text, link, iconCls, path) {
			var tab = this.getComponent(id);
			if (tab != null) {
				this.setActiveTab(tab);
				return;
			}
			this.add({
				id : id,
				title:"&nbsp;&nbsp;" + text + "&nbsp;&nbsp;",
				closable: true,
				html: "<iframe width='100%' frameborder='0' height='100%' src='" + link + "'></iframe>",
				listeners : {
					show : {
						fn : function(){
							menuTree.selectPath(path);
						}
					}
				}
			}).show();
		}
	});
	
	var view = Ext.create('Ext.container.Viewport', {
		layout : 'border',
		type: 'border',
        padding: 2,
		renderTo : Ext.getBody(),
		items : [header, menuTree, tabs]
	});
});